package de.lulusoft.anothertorrent.core.xmlrpc;

import org.apache.xmlrpc.serializer.TypeSerializerImpl;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

public class CustomI8Serializer extends TypeSerializerImpl {

	public static final String P_I8 = "i8";
	public static final String P_I4 = "i4";
	
	private boolean i8Support = false;
	
	public CustomI8Serializer(boolean isI8Supported) {
		super();
		i8Support = isI8Supported;
	}

	@Override
	public void write(ContentHandler pHandler, Object pObject) throws SAXException {
		if (i8Support) {
			write(pHandler, P_I8, P_I8, pObject.toString());
		}
		else {
			write(pHandler, P_I4, P_I4, pObject.toString());
		}
		
	}

}
